//
//  BRFaultItemView.m
//  BrezzeSaaS
//
//  Created by IOS on 2021/10/8.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import "BRFaultItemView.h"
@interface BRFaultItemView ()
{
    UIImageView *_selImg;
    QMUILabel *_textL;
    UIImage *_singleImg;
    UIImage *_singleImgUn;
}

@end

@implementation BRFaultItemView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setIsSelected:(BOOL)isSelected {
    _isSelected = isSelected;
    _selImg.image = isSelected == YES ? _singleImg : _singleImgUn;
    
    self.layer.borderColor = isSelected == YES ? kUIColorMainTint.CGColor : UIColorMakeWithHex(@"#D2D8E2").CGColor;
    self.layer.borderWidth = isSelected == YES ? 2 : 0.5;
    self.backgroundColor = isSelected == YES ? UIColor.whiteColor : UIColorClear;
}

- (void)setNumOfLine:(NSInteger)numOfLine {
    _numOfLine = numOfLine;
    _textL.numberOfLines = numOfLine;
}

- (void)setText:(NSString *)text {
    _text = text;
    _textL.text = text;
    [_textL sizeToFit];
}


- (void)setIsSingle:(BOOL)isSingle {
    _isSingle = isSingle;
    _singleImg = isSingle == YES ? UIImageMake(@"faq_signlSel") : UIImageMake(@"faq_sel");
//    _singleImgUn = isSingle == YES ? UIImageMake(@"faq_signlUnsel") : UIImage.qd_fbUnSelImg;
}

- (void)setUI {
    
    self.layer.cornerRadius = 10;
    self.layer.masksToBounds = YES;
    self.layer.borderColor = UIColorMakeWithHex(@"#D2D8E2").CGColor;
    self.layer.borderWidth = 0.5;
    
    _singleImgUn = UIImageMake(@"faq_signlUnsel");
    _singleImg = UIImageMake(@"faq_signlSel");
    self.backgroundColor = UIColorClear;
    self.userInteractionEnabled = YES;
    UIImageView *seImg = [[UIImageView alloc] init];
    seImg.image = _singleImgUn;
    [self addSubview:seImg];
    [seImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.mas_equalTo(14);
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-16);
    }];
    
    _numOfLine = 2;
    QMUILabel *titleL = [[QMUILabel alloc] init];
    titleL.textAlignment = NSTextAlignmentLeft;
    titleL.textColor = kColorTitle;
    titleL.text = @"--";
    titleL.font = [UIFont fontM:14];
    titleL.numberOfLines = _numOfLine;
    [self addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-40);
        make.centerY.offset(0);
        make.left.offset(16);
//        make.top.equalTo(self).offset(12);
//        make.bottom.equalTo(self).offset(-12);
    }];
    titleL.userInteractionEnabled  =  YES;
    
    _selImg = seImg;
    _textL = titleL;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
